package com.gitee.wsl.time.schedule.ext

import com.gitee.wsl.ext.base.currentTime
import com.gitee.wsl.time.schedule.TimeScheduler
import kotlin.time.ExperimentalTime
import kotlin.time.Instant

@OptIn(ExperimentalTime::class)
fun TimeScheduler.nextOrRelative(relatively: Instant = currentTime): Instant = next(relatively).getOrNull() ?: getAnyNext(relatively)
@OptIn(ExperimentalTime::class)
fun TimeScheduler.nextOrNow(): Instant = currentTime.let {
    next(it,it).getOrNull() ?: getAnyNext(it)
}